package com.br.dnaklass.tests;

import java.lang.reflect.Field;
import java.util.List;

import com.br.dnaklass.core.FamilyTree;

@SuppressWarnings( "rawtypes" )
public class TestSon extends TestFather {
	private String nameSon;
	
	public static void main( String[] args ) {
		TestSon test = new TestSon();
		List<Class> parents = FamilyTree.getParents(test.getClass());
		for ( Class class1 : parents ) {
			System.out.println(class1.getSimpleName());
		}
		for ( Class klass : parents ) {
			for ( Field field : klass.getDeclaredFields() ) {
				try {
					field.setAccessible( true );
					field.set( klass.cast( test ), "savio" + klass.getSimpleName()  );
				} catch ( IllegalArgumentException e ) {
					e.printStackTrace();
				} catch ( IllegalAccessException e ) {
					e.printStackTrace();
				}
			}
		}
		System.out.println(test.toString());
	}

	public String getNameSon() {
		return nameSon;
	}

	public void setNameSon( String nameSon ) {
		this.nameSon = nameSon;
	}

	@Override
	public String toString() {
		return "TestSon [nameSon=" + nameSon + "; nameFather="+getNameFather()+"; nameGranFather="+getNameGranFather()+"]";
	}
	
}
